#!/bin/bash
# filepath: /Users/aibokalv/Mycode/typing_pc_nuxt/scripts/analyze-build.sh

set -e

echo "📊 开始构建分析..."

# 构建并分析
pnpm build:analyze

# 分析构建产物
echo "📁 .output 目录结构："
tree .output 2>/dev/null || find .output -type f | head -20

echo ""
echo "📦 主要文件大小："
find .output -name "*.js" -o -name "*.css" | xargs du -h | sort -hr | head -10

echo ""
echo "🎯 代码分割效果："
find .output/public/_nuxt -name "*.js" | wc -l | xargs echo "JS chunks:"
find .output/public/_nuxt -name "*.css" | wc -l | xargs echo "CSS chunks:"

echo ""
echo "💾 总构建大小："
du -sh .output/public